//
//  ViewController.m
//  ArchitectDemo
//
//  Created by 姚胜龙 on 2017/6/13.
//  Copyright © 2017年 姚胜龙. All rights reserved.
//

#import "ViewController.h"
#import "StudentModel.h"
#import "StudentModel2.h"
#import "TeacherModel.h"
#import "TeacherModel2.h"
#import "Assemble.h"
#import "LevenoComputerBuilder.h"
//创建模式
#import "Builder.h"
#import "SLAlertController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    //系统copy测试
//    TeacherModel *techer1 = [[TeacherModel alloc] initWithName:@"Jack"];
//    TeacherModel *techer2 = [[TeacherModel alloc] initWithName:@"Lisa"];
//
//    StudentModel *student1 = [[StudentModel alloc] initWithName:@"Mimi" teachers:@[techer1, techer2]];
//    StudentModel *studentCopy = student1.copy;
//    studentCopy.teachers[0].teacherName = @"Meson";
//
//    NSLog(@"student1.teachers[0].teacherName = %@", student1.teachers[0].teacherName);
//    NSLog(@"studentCopy.teachers[0].teacherName = %@", studentCopy.teachers[0].teacherName);

    // 深拷贝测试
//    TeacherModel2 *techer1 = [[TeacherModel2 alloc] initWithName:@"Jack"];
//    TeacherModel2 *techer2 = [[TeacherModel2 alloc] initWithName:@"Lisa"];
//
//    StudentModel2 *student1 = [[StudentModel2 alloc] initWithName:@"Mimi" teachers:@[techer1, techer2]];
//    StudentModel *studentCopy = student1.deepCopy;
//    studentCopy.teachers[0].teacherName = @"Meson";
//
//    NSLog(@"student1.teachers[0].teacherName = %@", student1.teachers[0].teacherName);
//    NSLog(@"studentCopy.teachers[0].teacherName = %@", studentCopy.teachers[0].teacherName);

    //builder模式测试
    //第一种写法（比较少）
//    id<IComputerBuilder> builder = [[LevenoComputerBuilder alloc] init];
//    Assemble *assemble = [[Assemble alloc] initWithBuilder:builder];
//    [assemble constructComputerCPU:@"inter i5" display:@"独立显卡2G" mainboard:@"三星主板" os:@""];
//    //第二种写法 （经常用到,我们也经常这样写）
//    id<IComputerBuilder> builder2 = [[LevenoComputerBuilder alloc] init];
//    //链式编程
//    [[[[[builder2 buildCPU:@"inter i5"] buildDisplay:@"独立显卡2G"] buildMainboard:@"三星主板"] buildOS:@""] build];

}

- (IBAction)showAlertView:(id)sender {
     //-------Builder模式增强案例测试-----------------
    Builder *builder = [SLAlertController construt:self];
    [[[[[[[[builder setTitle:@"提示"] setMessage:@"确定要删除这张图片吗？"] setConfirmTitle:@"确定"] setConfirmHandler:^(UIAlertAction * _Nullable action) {
        NSLog(@"点击了确定");

    }] setCancelTitle:@"取消"] setCancelHandler:^(UIAlertAction * _Nullable action) {
        NSLog(@"点击了取消");
    }] build] showAlert];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
